%%
%% This is file `luamml-pdf.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% luamml.dtx  (with options: `package,pdftex')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from luamml-pdf.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file luamml.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% Copyright (C) 2020-2025 by Marcel Krueger
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
\ProvidesExplPackage {luamml-pdf} {2025-10-20} {0.7.0}
  {MathML generation for L̶u̶a̶pdfLaTeX}
\int_new:N \l__luamml_flag_int
\int_new:N \l__luamml_pretty_int
\tl_new:N \l__luamml_root_tl
\tl_set:Nn \l__luamml_root_tl { mrow }
\tl_new:N \l__luamml_label_tl
\int_new:N \g__luamml_formula_id_int

\int_set:Nn \l__luamml_pretty_int { 1 }

\cs_new_protected:Npn \luamml_process: {
  \tl_set:Nn \l__luamml_label_tl {}
  \int_set:Nn \l__luamml_flag_int { 3 }
}
\cs_set_eq:NN \luamml_flag_process: \luamml_process:
\cs_new:Npn \__luamml_maybe_structelem: {
  (
    8 * \int_mod:nn {
      \int_div_truncate:nn { \l__luamml_flag_int } {8}
    } {2}
  ) +
}
\cs_new:Npn \__luamml_style_to_num:N #1 {
  \token_case_meaning:NnF #1 {
    \displaystyle {0}
    \textstyle {32}
    \scriptstyle {64}
    \scriptscriptstyle {96}
  } {
    \Invalid_mathstyle
  }
}
\cs_new_protected:Npn \luamml_save:n #1 {
  \tl_set:Nn \l__luamml_label_tl {#1}
  \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 1 }
}
\cs_new_protected:Npn \luamml_save:nN #1#2 {
  \tl_set:Nn \l__luamml_label_tl {#1}
  \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 17 + \__luamml_style_to_num:N #2 }
}
\cs_new_protected:Npn \luamml_save:nn #1 {
  \tl_set:Nn \l__luamml_label_tl {#1}
  \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 5 }
  \tl_set:Nn \l__luamml_root_tl
}
\cs_new_protected:Npn \luamml_save:nNn #1#2 {
  \tl_set:Nn \l__luamml_label_tl {#1}
  \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 21 + \__luamml_style_to_num:N #2 }
  \tl_set:Nn \l__luamml_root_tl
}
\cs_set_eq:NN \luamml_flag_save:n \luamml_save:n
\cs_set_eq:NN \luamml_flag_save:nN \luamml_save:nN
\cs_set_eq:NN \luamml_flag_save:nn \luamml_save:nn
\cs_set_eq:NN \luamml_flag_save:nNn \luamml_save:nNn
\cs_new_protected:Npn \luamml_ignore: {
  \int_set:Nn \l__luamml_flag_int { 0 }
}
\cs_set_eq:NN \luamml_flag_ignore: \luamml_ignore:
\luamml_process:

\cs_if_exist:NTF \showstream {
  \iow_new:N \l__luamml_pdf_stream
  \iow_open:Nn \l__luamml_pdf_stream { \jobname .tml }
  \cs_new_protected:Npn \__luamml_pdf_showlists: {
    \group_begin:
      \int_set:Nn \tex_showboxdepth:D { \c_max_int }
      \int_set:Nn \tex_showboxbreadth:D { \c_max_int }
      \showstream = \l__luamml_pdf_stream
      \tex_showlists:D
    \group_end:
  }
} {
  \cs_set_eq:NN \l__luamml_pdf_stream \c_log_iow
  \cs_set_eq:NN \__luamml_pdf_set_showstream: \scan_stop:
  \cs_new_protected:Npn \__luamml_pdf_showlists: {
    \group_begin:
      \int_set:Nn \l_tmpa_int { \tex_interactionmode:D }
      \int_set:Nn \tex_interactionmode:D { 0 }
      \int_set:Nn \tex_showboxdepth:D { \c_max_int }
      \int_set:Nn \tex_showboxbreadth:D { \c_max_int }
      \tex_showlists:D
      \int_set:Nn \tex_interactionmode:D { \l_tmpa_int }
    \group_end:
  }
}
\cs_generate_variant:Nn \tl_to_str:n { e }
\int_new:N \g__luamml_annotation_id_int
\cs_new_protected:Npn \luamml_annotate:nen #1#2#3 {
  \int_gincr:N \g__luamml_annotation_id_int
  \iow_shipout_x:Nx \l__luamml_pdf_stream {
    LUAMML_MARK_REF:
    \int_use:N \g__luamml_annotation_id_int
    :
  }
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_MARK:
    \int_use:N \g__luamml_annotation_id_int
    :
    count = \int_eval:n {#1},
    #2
    \iow_newline:
    LUAMML_MARK_END
  }
  #3
}
\cs_new_protected:Npn \luamml_annotate:en #1#2 {
  \int_gincr:N \g__luamml_annotation_id_int
  \iow_shipout_x:Nx \l__luamml_pdf_stream {
    LUAMML_MARK_REF:
    \int_use:N \g__luamml_annotation_id_int
    :
  }
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_MARK:
    \int_use:N \g__luamml_annotation_id_int
    :
    count = data.count[\int_use:N \g__luamml_annotation_id_int],
    #1
    \iow_newline:
    LUAMML_MARK_END
  }
  \use:x {
    \iow_now:Nn \l__luamml_pdf_stream {
      LUAMML_COUNT:
      \int_use:N \g__luamml_annotation_id_int
    }
    \__luamml_pdf_showlists:
    \exp_not:n {#2}
    \iow_now:Nn \l__luamml_pdf_stream {
      LUAMML_COUNT_END:
      \int_use:N \g__luamml_annotation_id_int
    }
    \__luamml_pdf_showlists:
  }
}
\cs_new_protected:Npn \luamml_pdf_write: {
  \int_gincr:N \g__luamml_formula_id_int
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_FORMULA_BEGIN:
    \int_use:N \g__luamml_formula_id_int
    :
    \int_use:N \l__luamml_flag_int
    :
    \l__luamml_root_tl
    :
    \l__luamml_label_tl
  }
  \__luamml_pdf_showlists:
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_FORMULA_END
  }
}
\NewDocumentCommand \RegisterFamilyMapping {m m} {
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_INSTRUCTION:REGISTER_MAPPING: \int_use:N #1 : #2
  }
}
\str_if_exist:cF { l__socket_tagsupport/math/luamml/save/nn_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/save/nn}{1}
   \AssignSocketPlug{tagsupport/math/luamml/save/nn}{noop}
   \NewSocket{tagsupport/math/luamml/save/nNn}{1}
   \AssignSocketPlug{tagsupport/math/luamml/save/nNn}{noop}
 }
\NewSocketPlug{tagsupport/math/luamml/save/nNn}{luamml}
 {
   \luamml_save:nNn #1
 }
\AssignSocketPlug{tagsupport/math/luamml/save/nNn}{luamml}
\NewSocketPlug{tagsupport/math/luamml/save/nn}{luamml}
 {
   \luamml_save:nn #1
 }
\AssignSocketPlug{tagsupport/math/luamml/save/nn}{luamml}
\str_if_exist:cF { l__socket_tagsupport/math/luamml/annotate/false_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/annotate/false}{2}
   \NewSocketPlug{tagsupport/math/luamml/annotate/false}{default}{#2}
   \AssignSocketPlug{tagsupport/math/luamml/annotate/false}{default}
 }
\str_if_exist:cF { l__socket_tagsupport/math/luamml/array/finalize_plug_str }
  {
     \NewSocket{tagsupport/math/luamml/array/save}{0}
     \NewSocket{tagsupport/math/luamml/array/finalize}{0}
     \NewSocket{tagsupport/math/luamml/array/initcol}{0}
     \NewSocket{tagsupport/math/luamml/array/finalizecol}{1}
     \AssignSocketPlug{tagsupport/math/luamml/array/finalizecol}{noop}
  }
\str_if_exist:cF { l__socket_tagsupport/math/luamml/mtable/finalizecol_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/mtable/finalizecol}{1}
 }
\str_if_exist:cF { l__socket_tagsupport/math/luamml/mtable/innertable/save_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/mtable/innertable/save}{0}
   \NewSocket{tagsupport/math/luamml/mtable/smallmatrix/save}{0}
   \NewSocket{tagsupport/math/luamml/mtable/innertable/finalize}{0}
 }
\str_if_exist:cF { l__socket_tagsupport/math/luamml/mtable/finalize_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/mtable/finalize}{1}
   \AssignSocketPlug{tagsupport/math/luamml/mtable/finalize}{noop}
 }
\str_if_exist:cF { l__socket_tagsupport/math/luamml/mtable/aligncol_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/mtable/aligncol}{1}
   \AssignSocketPlug{tagsupport/math/luamml/mtable/aligncol}{noop}
 }

\str_if_exist:cF { l__socket_tagsupport/math/luamml/mtable/tag/save_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/mtable/tag/save}{0}
   \NewSocket{tagsupport/math/luamml/mtable/tag/set}{0}
 }
\str_if_exist:cF { l__socket_tagsupport/math/display/tag/begin_plug_str }
 {
   \NewSocket{tagsupport/math/display/tag/begin}{0}
   \NewSocket{tagsupport/math/display/tag/end}{0}
 }
\str_if_exist:cF { l__socket_tagsupport/math/luamml/hbox_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/hbox}{2}
   \NewSocketPlug{tagsupport/math/luamml/hbox}{default}{#2}
   \AssignSocketPlug{tagsupport/math/luamml/hbox}{default}
 }
\str_if_exist:cF { l__socket_tagsupport/math/luamml/artifact_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/artifact}{0}
 }
\str_if_exist:cF { l__socket_tagsupport/math/luamml/finph@nt_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/finph@nt}{2}
   \NewSocketPlug{tagsupport/math/luamml/finph@nt}{default}{#2}
   \AssignSocketPlug{tagsupport/math/luamml/finph@nt}{default}
 }

\str_if_exist:cF { l__socket_tagsupport/math/luamml/finsm@sh_plug_str }
 {
   \NewSocket{tagsupport/math/luamml/finsm@sh}{2}
   \NewSocketPlug{tagsupport/math/luamml/finsm@sh}{default}{#2}
   \AssignSocketPlug{tagsupport/math/luamml/finsm@sh}{default}
 }
\cs_new_protected:Npn \__luamml_patch_package:nn #1 #2 {
  \@ifpackageloaded {#1} {#2} {
    \hook_gput_code:nnn {package/#1/after} {luamml} {#2}
  }
}
\cs_new_protected:Npn \__luamml_patch_package:n #1 {
  \__luamml_patch_package:nn {#1} {
    \RequirePackage { luamml-patches-#1 }
  }
}
\RequirePackage { luamml-patches-kernel }

\endinput
%%
%% End of file `luamml-pdf.sty'.
